
  document.getElementById('uid').addEventListener('click',function close() {
       var uid=getcookie("uid");
       $('#myModal').modal('show');
      
	 	$('#input_uid').val(uid);
    });
    //百度地图API最后还是调用Google的地图查询 还得要VPN 我吐了
 document.getElementById('inschool').addEventListener('click',function close() {
 	var place;
 	var map = new BMap.Map("allmap");
 	var point = new BMap.Point(116.331398,39.897445);
	map.centerAndZoom(point,12);
	var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r){
    if(this.getStatus() == BMAP_STATUS_SUCCESS){
        var mk = new BMap.Marker(r.point);
        map.addOverlay(mk);
        map.panTo(r.point);
        alert('您的位置：'+r.point.lng+','+r.point.lat);
        place=r.point.lng+','+r.point.lat; 
  		var uid=getcookie("uid");
 $.ajax({
	   url:"InorLeave",
	   method:"post",
	    data:{
	    Uid:uid,
	    InorLeave:0,
	    Place:place},
	   dataType:"json",
	   success:function(data){
	   if(data.status=="success")
	   alert("进校签到成功");
	   else if(data.status=="fail")
	   alert("输入身份证不存在或者有误");
	   },
	   error:function(data)
	   { alert("no");}
	   });
        }
    else {
        alert('failed'+this.getStatus());
    }        
});
    });
 document.getElementById('leaveschool').addEventListener('click',function close() {
  	var place;
 	var map = new BMap.Map("allmap");
 	var point = new BMap.Point(116.331398,39.897445);
	map.centerAndZoom(point,12);
	var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r){
    if(this.getStatus() == BMAP_STATUS_SUCCESS){
        var mk = new BMap.Marker(r.point);
        map.addOverlay(mk);
        map.panTo(r.point);
        alert('您的位置：'+r.point.lng+','+r.point.lat);
        place=r.point.lng+','+r.point.lat; 
 		 var uid=getcookie("uid");
 $.ajax({
	   url:"InorLeave",
	   method:"post",
	    data:{
	    Uid:uid,
	    InorLeave:1,
	    Place:place},
	   dataType:"json",
	   success:function(data){
	   if(data.status=="success")
	   alert("出校签到成功");
	   else if(data.status=="fail")
	   alert("输入身份证不存在或者有误");
	   },
	   error:function(data)
	   { alert("no");}
	   });
        }
    else {
        alert('failed'+this.getStatus());
    }        
});
    });
function uid_submit(){
	deletecookie("uid");
	var value=document.getElementById("input_uid").value;
 	setcookie("uid",value,3600*24*365);
 	alert("保存成功"); 
 	$('#input_uid').val(value); 
}
function setcookie(name, value, time) {
        var exp = new Date();
        exp.setTime(exp.getTime() + time * 1);    
        //设置cookie的名称、值、失效时间
        document.cookie = name + "=" + value + ";expires="+ exp.toGMTString();
         
    }
function getcookie(name) {
        //获取当前所有cookie
       var reg = eval("/(?:^|;\\s*)" + name + "=([^=]+)(?:;|$)/");
       return reg.test(document.cookie) ? RegExp.$1 : "";
    }
function deletecookie(name) {
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        //获取cookie是否存在
        var value = getcookie(name);
        if (value != null) {
            document.cookie = name + "=" + value + ";expires="+ exp.toUTCString();
        }
   }